import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_demo/getx/count_controller.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  CountController countController = Get.find(); // 获取controller实例

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("登录页面"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              Get.arguments == [] ? Get.arguments['text'] : 'default arguments',
              style: const TextStyle(fontSize: 40),
            ),
            Obx(() => Text('${countController.count}',
                style: const TextStyle(color: Colors.blue, fontSize: 40))),
            ElevatedButton(
              onPressed: () {
                countController.dec();
              },
              child: const Text('减'),
            )
          ],
        ),
      ),
    );
  }
}
